<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: gavin
 * Date: 15-5-10
 * Time: 下午3:56
 */

class Xueme_user_model extends CI_Model
{

    public function __construct()
    {
        parent::__construct();
        //装载database
        $this->load->database();
    }

    public function insert($id,$name,$loginname,$loginpasswd,$salt,$email,$phone,$gender,$regist_time,$last_login=null)
    {
        $value['id'] = $id;
        $value['name'] = $name;
        $value['loginname'] = $loginname;
        $value['loginpasswd'] = $loginpasswd;
        $value['salt'] = $salt;
        $value['email'] = $email;
        $value['phone'] = $phone;
        $value['gender'] = $gender;
        $value['regist_time'] = $regist_time;
        $value['last_login'] = $last_login;
        $this->db->insert('xueme_user',$value);
    }

    public function insertValue($value)
    {
        $this->db->insert('xueme_user',$value);
    }

    public function existUser($loginname,$loginpasswd)
    {
        $sql = sprintf("select * from %s where loginname like '%s' and loginpasswd like '%s'",'xueme_user',$loginname,$loginpasswd);
        $query = $this->db->query($sql);
        return $query->result();
    }

    public function existUserName($loginname)
    {
        $sql = sprintf("select * from %s where loginname like '%s' ",'xueme_user',$loginname);
        $query = $this->db->query($sql);
        return $query->result();
    }
}
